<template>
    <view>
        <view class="list" v-for="(item, index) in pageData" :key="index" @click="toListDetails(item)">
            <image :src="$imgUrls(item.img)" mode="aspectFill" class="Img"></image>
            <view class="content">
                <text class="name ellipsis">{{ item.name }}</text>
                <view class="tagBox" v-if="item.classify_tag && item.classify_tag.length">
                    <view class="liTag" v-for="(tag, tain) in item.classify_tag.slice(0, 3)" :key="tain">{{ tag }}</view>
                </view>
                <text class="info ellipsis">{{ item.info }}</text>
                <view class="serverBox">
                    <u-rate :count="5" v-model="item.star" readonly allowHalf :gutter="2" inactiveColor="#cecece" activeColor="#FF3355"></u-rate>
                    <text class="sales_number" v-if="item.sales_number">累计服务：{{ item.sales_number }}</text>
                </view>
            </view>
        </view>

        <emptys v-if="!pageData.length"></emptys>
    </view>
</template>

<script>
    export default {
        props: ['topping', 'classify_id', 'pageData'],
        data() {
            return {
                // pageData: []
            };
        },
        created() {
            // this.sortClassGoods();
        },
        methods: {
            sortClassGoods() {
                this.$http
                    .get({
                        url: '/singleSaleApi/sortClassGoods',
                        data: {
                            topping: this.topping,
                            classify_id: this.classify_id,
                            classify_cate: 5
                        }
                    })
                    .then((res) => {
                        if (res.code != 100) return this.$Toast(res.msg);
                        const result = res.data.DataArr || [];
                        this.pageData = result;
                    });
            },
            toListDetails(Item) {
                this.toUrl(`/zunyi/details?goods_id=${Item.goods_id}`);
            }
        }
    };
</script>

<style lang="scss" scoped>
    .list {
        width: 700rpx;
        margin: 28rpx auto 0;
        background-color: #ffffff;
        border-radius: 10rpx;
        padding: 20rpx;
        display: flex;
        box-shadow: rgba(149, 157, 165, 0.2) 0px 8rpx 24rpx;
        .Img {
            width: 178rpx;
            height: 178rpx;
            border-radius: 10rpx;
            margin-right: 20rpx;
        }
        .content {
            flex: 1;
            display: flex;

            flex-direction: column;
            justify-content: space-between;
            .name {
                color: #000;
                font-size: 32rpx;
            }
            .tagBox {
                width: 100%;
                display: flex;
                .liTag {
                    padding: 2rpx 14rpx;
                    background-color: #edf5ff;
                    color: #28adf2;
                    border-radius: 8rpx;
                    margin: 0 12rpx 0 0;
                }
                .liTag:last-child {
                    margin-right: 0;
                }
            }
            .info {
                color: #333333;
                font-size: 24rpx;
            }
            .serverBox {
                width: 100%;
                display: flex;
                align-items: center;
                justify-content: space-between;
                .sales_number {
                    color: #666666;
                    font-size: 24rpx;
                }
            }
        }
    }
</style>
